import { request } from '@/utils/request'
import type { TUser, CodeType, UserInfo, Patient } from '@/types/user'
// TUser的是调用接口后要定义返回数据类型
// 密码登录
export function loginPassword(mobile: string, password: string) {
  return request<TUser>('post', '/login/password', { mobile, password })
}
// 获取验证码
export function sendMobileCode(mobile: string, type: CodeType) {
  return request<{ code: string }>('get', '/code', { mobile, type })
}
// 验证码登录
export function loginCode(mobile: string, code: string) {
  return request<TUser>('post', '/login', { mobile, code })
}
// 获取用户个人信息
export function patientMyUser() {
  return request<UserInfo>('get', '/patient/myUser')
}
// 获取患者信息
export function patientMylist() {
  return request<Patient[]>('get', '/patient/mylist')
}
// 添加患者
export function patientAdd(patient: Patient) {
  return request('post', '/patient/add', patient)
}
// 编辑患者
export function patientUpdate(obj: Patient) {
  return request('put', '/patient/update', obj)
}
// 删除患者
export function patientDel(id: string | number) {
  return request('delete', `/patient/del/${id}`)
}
// 9. 问诊-查询患者详情
export const getPatientDetail = (id: string) => request<Patient>('get', `/patient/info/${id}`)
